import { defineConfig } from '@tarojs/cli';
import version from './version';

const target = 'http://www.fly.com';
let API_URL = '""';
if (process.env.TARO_ENV === 'weapp') {
  API_URL = `'${target}'`;
}
module.exports = defineConfig({
  env: {
    NODE_ENV: '"development"',
  },
  // plugins: ['@tarojs/plugin-mock'],
  defineConstants: {
    BUILD_ENV: '"local"',
    //小程序无代理需要填写url
    API_URL: API_URL,
    VERSION: version.VERSION,
    SIGN_KEY: version.SIGN_KEY,
    APP_ID: version.APP_ID,
    OSS_URL: version.OSS_URL,
  },
  mini: {},
  h5: {
    sourceMapType: 'source-map',
    // sourceMapType: 'eval-cheap-module-source-map',
    devServer: {
      client: {
        overlay: false,
      },
      // headers: {
      //   'Access-Control-Allow-Origin': '*', //钉钉本地调试工具
      // },
      // host: '127.0.0.1',
      // allowedHosts: 'all',//如果使用代理转发可以开启调试
      port: 8080,
      proxy: {
        '/api': {
          target: target,
          changeOrigin: true,
        },
        '/wechat': {
          target: target,
          changeOrigin: true,
        },
      },
    },
  },
});
